package com.babyqiao.wallpaper.manager.controller;

import com.babyqiao.wallpaper.manager.service.LocalStorageService;
import com.babyqiao.wallpaper.common.UnifyResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author qinglongzhai
 * @date 2020/12/9
 */
@RestController
@RequestMapping("/api/admin/local")
@Api(tags = "本地存储接口")
public class LocalStorageController {
    @Autowired
    private LocalStorageService localStorageService;

    @PostMapping("/file")
    @ApiOperation(value = "上传封面", httpMethod = "POST")
    public UnifyResult uploadLocalStorageFile(MultipartFile file) throws IOException {
        //获取上传文件
        String url = localStorageService.uploadFileCover(file);
        System.out.println(file);


        return UnifyResult.success().data("result", url);
    }


}
